﻿using MediatR;
using T_vehicle.API.Application.Command.TiresUsedCommand;
using T_vehicle.Infrastructure.Interfacec;

namespace T_vehicle.API.Application.CommandHandlers.TiresUsedCommandHandlers
{
    public class DelTiresUsedCommandHandlers : IRequestHandler<DelTiresUsedCommand, int>
    {
        private readonly ITiresUsedRepository tiresUsedRepository;

        public DelTiresUsedCommandHandlers(ITiresUsedRepository tiresUsedRepository)
        {
            this.tiresUsedRepository = tiresUsedRepository;
        }

        public async Task<int> Handle(DelTiresUsedCommand request, CancellationToken cancellationToken)
        {
            var list = await tiresUsedRepository.GetModelAsync(request.TiresUsedId);
            list.IsDel = true;
            var res = await tiresUsedRepository.UpdateAsync(list);
            return res;
        }
    }
}
